/*
 * @Author: Setsuna
 * @Email: setsuna.xyz@qq.com
 * @FilePath: \src\lib\types\page.ts
 * @Date: 2022-12-05 10:44:43
 * @LastEditTime: 2022-12-22 19:58:23
 * @LastEditors: Setsuna
 */
import { RouteComponentProps } from 'react-router'
import { ReactNode } from 'react'
import { IUdColumn, IUdFormItem, IUdTableProps } from '.'
import { PaginationConfig } from 'antd/lib/table'
import { IUdDetailItem } from '../ui/UdDetail'
import { Value } from 'classnames'


export interface IBaseListPageProps<Params extends { [K in keyof Params]?: string } = {}>
  extends RouteComponentProps<Params> {

}

export interface IBaseListPageState<T = any> {
  title?: string
  subTitle?: string
  method?: 'GET' | 'POST'
  queryAfterMount?:boolean
  queryApi: string | ((data: any) => Promise<any>)
  /** 检索条件集合 */
  conditions?: IUdFormItem[]
  /** 检索状态 */
  querying?: boolean

  leftBtns?: (ReactNode | (() => ReactNode))[]
  rightBtns?: (ReactNode | (() => ReactNode))[]

  rowKey: string | ((record: T, index: number) => string)
  columns: IUdColumn<T>[]
  dataSource?: T[]
  tableProps?: IUdTableProps<T>
  pagination?: PaginationConfig | false
  showColumns?: string[]
  /**
   * table 表格勾选  id集合
   */
  selectedRowKeys?: string[] | number[]
  /**
   * table 表格勾选  数据
   */
  selectedRows?: T[]

  /** 暂时无效 */
  useColumnCustomize?: boolean

  onBack?: boolean | (() => void)
}

export interface IListQueryParams {
  page: number
  size: number
  conditions: {
    [key: string]: any
  },
  v: number
}





export interface IBaseDetailPageProps<Params extends { [K in keyof Params]?: string } = {}> extends RouteComponentProps<Params> {

}

export interface IBaseDetailPageState {
  title: ReactNode | (() => ReactNode)
  subTitle?: ReactNode | (() => ReactNode)
  queryAction: () => Promise<any>
  querying?: boolean
  dataSource?: any
  className?: Value
}

export interface IUdDetailItemGroup {
  title: string
  content: IUdDetailItem<any>[] | ReactNode
}
